<?php

#[interface('Usb', '国际标准')]
interface Usb
{
    public function start();

    public function run();

    public function stop();
}

#[class('Upan', '小明生产的U盘')]
class Upan implements Usb
{
    public function start()
    {
        echo "<h3>usb start</h3>";
    }

    public function run()
    {
        echo "<h3>usb run</h3>";
    }

    public function stop()
    {
        echo "<h3>usb stop</h3>";
    }

    public function explode()
    {
        echo "<h3>usb explode</h3>";
    }
}

#[class('Upan2', '小红生产的U盘')]
class Upan2
{
    public function start()
    {
        echo "<h3>usb start</h3>";
    }

    public function run()
    {
        echo "<h3>usb run</h3>";
    }

    public function stop()
    {
        echo "<h3>usb stop</h3>";
    }

    public function explode()
    {
        echo "<h3>usb explode</h3>";
    }
}

$u1 = new Upan();
$u2 = new Upan2();

# 使用usb设备的产品(lenovo笔记本)
# 多态介入区分符合标准生产的usb产品
class useUsb
{
    public static function init(Usb $usb)
    {
        $usb->start();
        $usb->run();
        $usb->stop();
    }
}

# 多态 只有继承抽象函数的子类才可以调用父类的函数
# 函数可以根据类的父类或祖先不同而表现的相态和结果
useUsb::useUsb($u1);
useUsb::useUsb($u2);
